package com.example.demo.service.Impl;
import com.example.demo.dao.ILog;
import com.example.demo.model.Log;
import com.example.demo.service.ILogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Administrator 高欣月
 */
@Service
public class LogServiceImpl implements ILogService{
    @Autowired
    private ILog logMapper;
    @Override
    public int insertLog(Log log){
        int logValue=0;

        Log log1=new Log();
        log1.setLogid(log.getLogid());
        List<Log> getL=logMapper.getAllLog(log1);
//        log1.setWyid(log.getWyid());
//        List<Log> getL2=logMapper.getAllLog(log1);
        if(getL.size()>0){
            logValue=-1;

        }
//        else if (getL2.isEmpty()==true) {
//            logValue=-1;
//        }
        else{
            logValue=logMapper.insertLog(log);
        }

        return logValue;
    }

    @Override
    public List<Log> getAllLog(Log log) {


        return logMapper.getAllLog(log);
    }

    @Override
    public int updateLog(Log log) {
        int logValues=0;
        if(log.getLogid()!=0){



            logValues=logMapper.updateLog(log);
        }
        return logValues;
    }

    @Override
    public int deleteLog(Log log) {
        int logValues=0;
        if(log.getLogid()!=0)
        {
            //主键是否与其他表有关联

            logValues=logMapper.deleteLog(log);
        }
        return logValues;
    }

    @Override
    public Log getLog(Log log) {
        Log log1=new Log();
        if(log.getLogid()!=0){
            log1=logMapper.getLog(log);
        }
        return log1;
    }

}
